package com.ruijixiang.leetcode.everyday.leetcode2024.leetcode202409;

public class leetcode20240929 {
    public int timeRequiredToBuy(int[] tickets, int k) {
        int target=tickets[k];
        int res=0;
        for(int i=0;i<tickets.length;i++){
            if(i<=k){
                res+=Math.min(tickets[i],target);
            }else{
                res+=Math.min(tickets[i],target-1);
            }
        }
        return res;
    }
}
